/*
 *NOTE:Auto generated service implement
*/
package com.surfilter.modules.mainPage.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.surfilter.modules.com.dao.HtComDao;
import com.surfilter.modules.com.model.ComStatModel;
import com.surfilter.modules.com.model.HtComModel;
import com.surfilter.modules.mainPage.service.MainPageMgrService;
import com.surfilter.platform.base.model.ActionPermission;
import com.surfilter.platform.base.model.PageInfo;
import com.surfilter.platform.base.model.ParameterClassType;
import com.surfilter.platform.base.model.ParameterInfo;
import com.surfilter.platform.base.model.ParameterMapper;
import com.surfilter.platform.base.model.PermissionMethodType;
import com.surfilter.platform.base.service.ServiceBase;

@Service(value = "mainPageMgrService")
public class MainPageMgrServiceImpl extends ServiceBase implements MainPageMgrService {

	@Resource
	private HtComDao htComDao;

	
	@ActionPermission(actionName = "addHtCom",remark = "添加小区信息")
	public java.lang.Integer addHtCom(HtComModel htComModel, HttpServletRequest request) {
		return htComDao.addHtCom(htComModel);
	}
	
	@ActionPermission(actionName = "chgHtCom",remark = "")
	public void chgHtCom(HtComModel htComModel, HttpServletRequest request) {
		htComDao.chgHtCom(htComModel);
	}
	
	@ActionPermission(actionName = "delHtCom",remark = "")
	public void delHtCom(HtComModel htComModel, HttpServletRequest request) {
		htComDao.delHtCom(htComModel);
	}
	
	@ActionPermission(actionName = "getHtComs",remark = "",permission=PermissionMethodType.MODULE)
	public List<HtComModel> getHtComs(HtComModel htComModel, HttpServletRequest request) {
		return htComDao.getHtComs(htComModel, PageInfo.getPageInfo(request));
	}
	@ActionPermission(actionName = "getComDetails",remark = "",permission=PermissionMethodType.MODULE)
	public List<HtComModel> getComDetails(HtComModel htComModel, HttpServletRequest request) {
		List<HtComModel> retList = htComDao.getHtComs(htComModel, PageInfo.getPageInfo(request));
		for (HtComModel model : retList) {
			Integer id = model.getId();
			if(id != null){
				ComStatModel stat = htComDao.getComStat(id);
				if(stat != null){
					model.setUserCount(stat.getUserCount());
					model.setCarCount(stat.getCarCount());
					model.setImpPosCount(stat.getImpPosCount());
					model.setImpUserCount(stat.getImpUserCount());
				}
			}
		}
		return retList;
	}
	
	@ActionPermission(actionName = "delHtComs",remark = "")
	@ParameterMapper({ @ParameterInfo(mapName = "ids", componentType = Integer.class, index = 0, mapType = ParameterClassType.ARRAY) })
	public boolean delHtComs(List<java.lang.Integer> ids){
		htComDao.delHtComs(ids);
		return true;
	}
	
	@ActionPermission(actionName = "getHtComsCount",remark = "")
	public int getHtComsCount(HtComModel htComModel) {
		return htComDao.getHtComsCount(htComModel);
	}
}
